import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import 'antd/dist/antd.css';
// 设置时间的语言
import 'moment/locale/zh-cn';
// import { HashRouter } from 'react-router-dom';
// import { Provider } from 'react-redux';
// import store from './store';
import Ctx, { initState } from './context';

window.DATA_MODE = 'prod';

// ReactDOM.render(
//   <HashRouter>
//     {/* 把store注入到App的上下文 */}
//     {/* 和vuex把store挂在vue实例上差不多的意思 */}
//     <Provider store={ store }>
//       <App />
//     </Provider>
//   </HashRouter>,
//   document.getElementById('root')
// );

function AppWithStore () {
  const [state, ogSetState] = useState(initState);

  function setState (newState) {
    ogSetState({
      ...state,
      ...newState,
    });
  }

  return (
    <Ctx.Provider value={{ state, setState }}>
      <App />
    </Ctx.Provider>
  );
}

ReactDOM.render(
  <AppWithStore />,
  document.getElementById('root')
);

